| Conditions | 2 |
| Total Lines | 13 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { QueryHandler } from '@nestjs/cqrs'; |
||
| 14 | |||
| 15 | public async execute({ code }: GetVoucherByCodeQuery): Promise<VoucherView> { |
||
| 16 | const voucher = await this.voucherRepository.findOneByCode(code); |
||
| 17 | |||
| 18 | if (!voucher) { |
||
| 19 | throw new VoucherNotFoundException(); |
||
| 20 | } |
||
| 21 | |||
| 22 | return new VoucherView( |
||
| 23 | voucher.getId(), |
||
| 24 | voucher.getCode(), |
||
| 25 | voucher.getEmail(), |
||
| 26 | voucher.getSchool().getId(), |
||
| 27 | ); |
||
| 30 |